home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Best of MacTutor - S…e Code for Volumes 1 to 5
/
The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin
/
Source Code
/
#06 (Feb 86)
/
pascal 2.2
/
Square_Wave_Scale
< prev
Wrap
Text File
|
1985-12-20
|
1KB
|
62 lines
program Square_Wave_scale;
const
notecount = 31;
type
Ptr = ^integer;
ParamBlockFake = array[0..30] of integer;
var
i : integer;
MySWSynthRec : record
mode : integer;
tones : array[1..notecount] of record
count, amplitude, duration : integer;
end;{ of tones }
end;{ of mySWSynthRec }
blockA, blockB : ParamBlockFake;{ for myStartSound }
AUsed : boolean;{ for MyStartSound }
procedure MyStartSound (SynthRec : ptr;
numbytes : longint;
CompletionRtn : Ptr);{ CompletionRtn ignored }
var
regs : array[0..12] of longint; { for generic }
BlockPtr : ^ParamBlockFake;
begin
if Aused then
BlockPtr := @BlockA
else
BlockPtr := @BlockB;
Aused := not Aused;
BlockPtr^[12] := -4;{ set ioRefNum }
BlockMove(@SynthRec, @BlockPtr^[16], 4);{ ioBuffer }
BlockMove(@numbytes, @BlockPtr^[18], 4);{ ioReqCount }
while BlockPtr^[8] <> 0 do { wait for ioResult }
;
{ The following two lines perform PBWrite(BlockPtr,true) }
regs[0] := ord(BlockPtr);{ set A0 for generic }
Generic($A403, regs);{ Write,async }
end;
begin
with MySWSynthRec do
begin
mode := SWMode;
for i := 1 to notecount do
with tones[i] do
begin
count := i * 64 + 256;
amplitude := 255 - i * 8;
duration := 30;{ 1/2 sec. }
end;
myStartSound(@MySWSynthRec, sizeof(MySWSynthRec), nil);
ShowText;
Writeln('press mouse to stop');
repeat
until button;
end;
StopSound;
end.